home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / opbonus.arc / ISRES.ARC / ISRES.ASM next >
Assembly Source File  |  1991-03-20  |  5KB  |  165 lines

  1. ;******************************************************
  2. ;                  ISRES.ASM 1.00
  3. ;        Copyright (c) TurboPower Software 1990.
  4. ;                All rights reserved.
  5. ;******************************************************
  6.  
  7. ;****************************************************** Equates
  8.  
  9. IfcSignature1   =       0F0F0h          ;Do not change
  10. IfcSignature2   =       0E0E0h          ;Do not change
  11. WP              EQU     WORD PTR
  12.  
  13. ;****************************************************** Structures
  14.  
  15. ;Structure of a pointer
  16. Pointer STRUC
  17.         Ofst    DW      0
  18.         Segm    DW      0
  19. Pointer ENDS
  20.  
  21. ;Structure of an IFC record
  22. IfcRec  STRUC
  23.         NamePtr         Pointer <>
  24.         Version         DW      0400h
  25.         UserPtr         Pointer <>
  26.         PrevIfc         Pointer <>
  27.         NextIfc         Pointer <>
  28.         PrgName         DB 9 DUP (0)
  29. IfcRec  ENDS
  30.  
  31. ;****************************************************** Macros
  32.  
  33. SetPtr          MACRO   P, S, O
  34.                 MOV     P.Ofst, O       ;set offset
  35.                 MOV     P.Segm, S       ;set segment
  36.                 ENDM
  37.  
  38. SetPtrByOfst    MACRO   P, S, O
  39.                 MOV     AX,Offset O
  40.                 MOV     P.Ofst, AX      ;set offset
  41.                 MOV     P.Segm, S       ;set segment
  42.                 ENDM
  43.  
  44. ;****************************************************** Data
  45.  
  46. DATA    SEGMENT BYTE PUBLIC
  47.  
  48.         EXTRN   ThisIfcPtr : DWORD
  49.         EXTRN   IfcInstalledPtr : DWORD
  50.  
  51. DATA    ENDS
  52.  
  53. ;****************************************************** Code
  54.  
  55. CODE    SEGMENT BYTE PUBLIC
  56.  
  57.         ASSUME  CS:CODE,DS:DATA
  58.  
  59.         PUBLIC  Init16, Restore16, ThisIfc
  60.  
  61. OldInt16        Pointer <>
  62. ThisIfc         IfcRec  <>
  63. IfcInstalled    DB      0
  64.  
  65. ;****************************************************** Int16
  66.  
  67. IntraApp        =       00F0h           ;offset of intraapplication comm area
  68. BiosDataSeg     =       40h             ;segment of BIOS data area
  69.  
  70. Int16   PROC NEAR
  71.  
  72.         STI                             ;Interrupts on
  73.         CMP     CS:IfcInstalled,1       ;Are we in charge of the interface?
  74.         JNE     JumpOld16               ;If not, chain to old ISR
  75.         CMP     AX,IfcSignature1        ;See if this is a request for info
  76.         JNE     NotIfcCheck1            ;If not, continue
  77.         NOT     AX                      ;Flip the bits in AX
  78.         PUSH    CS                      ;ES = CS
  79.         POP     ES
  80.         MOV     DI,Offset ThisIfc       ;ES:DI points to ThisIfc
  81.         MOV     WP ES:[DI].NextIfc,0    ;If we're answering this, we're the end
  82.         MOV     WP ES:[DI].NextIfc+2,0  ; of the line, so NextIfc is nil
  83.         IRET
  84.  
  85. NotIfcCheck1:
  86.         CMP     AX,IfcSignature2        ;Is this a secondary request?
  87.         JNE     JumpOld16
  88.         NOT     AX                      ;Flip the bits in AX
  89.         PUSH    ES                      ;save registers
  90.         PUSH    DI
  91.         PUSH    BX
  92.         PUSH    CX
  93.         MOV     CX,BiosDataSeg          ;ES:DI => intra-app comm area
  94.         MOV     ES,CX
  95.         MOV     DI,IntraApp
  96.         MOV     CX,CS                   ;CX:BX => ActualIfc
  97.         MOV     BX,Offset ThisIfc
  98.         MOV     ES:[DI].Ofst,BX         ;store @ThisIfc at Ptr(ES,DI)^
  99.         MOV     ES:[DI].Segm,CX
  100.         MOV     ES,CX                   ;ES:BX points to ThisIfc
  101.         MOV     WP ES:[BX].NextIfc,0    ;If we're answering this, we're the end
  102.         MOV     WP ES:[BX].NextIfc+2,0  ; of the line, so NextIfc is nil
  103.         POP     CX
  104.         POP     BX
  105.         POP     DI
  106.         POP     ES
  107.         IRET
  108.  
  109. JumpOld16:
  110.         CLI                             ;Interrupts off
  111.         JMP     DWORD PTR CS:OldInt16   ;Jump to old vector
  112.  
  113. Int16   ENDP
  114.  
  115. ;****************************************************** Init16
  116.  
  117. ;procedure Init16;
  118.  
  119. ;Capture INT 16
  120.  
  121. Init16  PROC FAR
  122.  
  123.         ;set up IFC
  124.         SetPtrByOfst    ThisIfc.NamePtr, CS, ThisIfc.PrgName
  125.  
  126.         ;give Pascal routines access to CS-relative data
  127.         SetPtrByOfst    ThisIfcPtr, CS, ThisIfc
  128.         SetPtrByOfst    IfcInstalledPtr, CS, IfcInstalled
  129.  
  130.         MOV     AX,3516h                ;Get the current INT $16 vector
  131.         INT     21h
  132.         SetPtr  CS:OldInt16, ES, BX     ;save it
  133.  
  134.         PUSH    DS                      ;save DS
  135.         PUSH    CS                      ;DS:DX => Int16
  136.         POP     DS
  137.         MOV     DX,Offset Int16
  138.         MOV     AX,2516h                ;take over the vector
  139.         INT     21h
  140.         POP     DS                      ;restore DS
  141.         RET
  142.  
  143. Init16  ENDP
  144.  
  145. ;****************************************************** Restore16
  146.  
  147. ;procedure Restore16;
  148.  
  149. ;Restore INT 16
  150.  
  151. Restore16       PROC FAR
  152.  
  153.         PUSH    DS                      ;save DS
  154.         LDS     DX,CS:OldInt16          ;DS:DX has old vector
  155.         MOV     AX,2516h                ;restore it
  156.         INT     21h
  157.         POP     DS                      ;restore DS
  158.         RET
  159.  
  160. Restore16       ENDP
  161.  
  162. CODE    ENDS
  163.  
  164.         END
  165.